<?php

$Request = Aero::load('libs/request');

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
	"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
	<meta http-equiv="Content-type" content="text/html; charset=utf-8">
	<title>Test request library</title>
	
</head>
<body>
	<h1>Test request library</h1>
	<pre>
// Request type
$Request->method(); // returns "<?= $Request->method() ?>"
$Request->is('get'); // returns "<?= $Request->is('get') ? 'true' : 'false' ?>"
$Request->is('post'); // returns "<?= $Request->is('post') ? 'true' : 'false' ?>"
$Request->is('put'); // returns "<?= $Request->is('put') ? 'true' : 'false' ?>"
$Request->is('delete'); // returns "<?= $Request->is('delete') ? 'true' : 'false' ?>"
$Request->is('remote'); // returns "<?= $Request->is('remote') ? 'true' : 'false' ?>"
$Request->is('ajax'); // returns "<?= $Request->is('ajax') ? 'true' : 'false' ?>"

// Request parameters
$Request->parameter('name','kuromaisu'); // returns "<?= $Request->parameter('name','kuromaisu') ?>"
$Request->data('surname','Muraviev'); // returns "<?= $Request->data('surname','Muraviev') ?>"
	</pre>
	<h2>Try these URIs</h2>
	<ul>
		<li><a href="/test_request">/test_request</a></li>
		<li><a href="/test_request/some/simple/uri">/test_request/some/simple/uri</a></li>
		<li><a href="/test_request/numbers/6/10">/test_request/numbers/6/10</a></li>
	</ul>
	
	<h2>These URIs will be rewritten</h2>
	<ul>
		<li><a href="/test_request/rewrite/into/another/uri">/test_request/rewrite/into/another/uri</a></li>
		<li><a href="/test_request/rewrite/1000/999">/test_request/rewrite/1000/999</a></li>
	</ul>
	<p>Here are the routes:</p>
	<pre><?php echo print_r(Aero::option('request.routes'),true) ?></pre>
	<h2>Sample Output</h2>
	<pre>
// Slices
$Request->uri->slice(); // returns "<?= $Request->uri->slice() ?>"
$Request->uri->slice(0); // returns "<?= $Request->uri->slice(0) ?>"
$Request->uri->slice(1); // returns "<?= $Request->uri->slice(1) ?>"
$Request->uri->slice(2); // returns "<?= $Request->uri->slice(2) ?>"
$Request->uri->slice(0,0); // returns "<?= $Request->uri->slice(0,0) ?>"
$Request->uri->slice(0,1); // returns "<?= $Request->uri->slice(0,1) ?>"
$Request->uri->slice(0,2); // returns "<?= $Request->uri->slice(0,2) ?>"
$Request->uri->slice(2,4); // returns "<?= $Request->uri->slice(2,4) ?>"

// Segments
$Request->uri->segment(0); // returns "<?= $Request->uri->segment(0,'nothing','required'); ?>"
$Request->uri->segment(1,'nothing','min_length[1]'); // returns "<?= $Request->uri->segment(1,'nothing','min_length[1]'); ?>"
$Request->uri->segment(2); // returns "<?= $Request->uri->segment(2); ?>"
$Request->uri->segment(3); // returns "<?= $Request->uri->segment(3); ?>"
	</pre>
	
</body>
</html>
